06. Lesson 2 Exercise

Lesson 2 Exercise

Overview

ND213 C04 L02 C2-5-A1

Code Discussion

ND213 C04 L02 C2-5-A2

Project Tasks

  • Task L2.1 : In method Vehicle::drive(), start up a task using std::async which takes a reference to the
    method Intersection::addVehicleToQueue, the object _currDestination and a shared pointer to this using the
    get_shared_this() function. Then, wait for the data to be available before proceeding to slow down.

  • Task L2.2 : In method Intersection::addVehicleToQueue(), add the new vehicle to the waiting line by
    creating a promise, a corresponding future and then adding both to _waitingVehicles. Then wait until
    the vehicle has been granted entry.

  • Task L2.3 : In method WaitingVehicles::permitEntryToFirstInQueue(), get the entries from the
    front of _promises and _vehicles. Then, fulfill promise and send signal back that permission to enter
    has been granted. Finally, remove the front elements from both queues.

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: react
  • Opened files (when workspace is loaded): n/a
  • userCode:

    export CXX=g++-7